﻿using System;
using System.Collections.Generic;
using System.Text;
using TSVNAddin.TSVN;

namespace TSVNAddin.Core
{
	public class DiffCommand : ICommand
	{
		private readonly ActiveDocumentAdapter _ActiveDocument;
		private readonly TortoiseProcExecutor _TortoiseProcExecutor;
		private readonly Repository _Repository;

		public DiffCommand(ActiveDocumentAdapter activeDocument, TortoiseProcExecutor tortoiseProcExecutor, Repository repository)
		{
			_ActiveDocument = activeDocument;
			_TortoiseProcExecutor = tortoiseProcExecutor;
			_Repository = repository;
		}

		public void Execute()
		{
			_TortoiseProcExecutor.Exec(TortoiseProcCommandType.Diff, _ActiveDocument.GetFileName());
		}

		public CommandStatus QueryStatus()
		{
			if (!_ActiveDocument.IsVersionable())
				return CommandStatus.VisibleAndDisabled;

			if (!_Repository.Contains(_ActiveDocument.GetFileName()))
				return CommandStatus.VisibleAndDisabled;

			return CommandStatus.VisibleAndEnabled;
		}
	}
}
